package com.zjnx.train.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import com.zjnx.train.dao.UserDao;
import com.zjnx.train.entity.User;
import com.zjnx.train.service.UserService;

/**
 * @author foo
 * @email foo@zjnx.com
 * @description:业务逻辑层
 */
@Service
@Transactional
public class UserServiceImpl implements UserService {
  @Autowired
  private UserDao userDao;

  @Override
  public void save(User user) {
    userDao.save(user);
  }

  @Override
  public void update(User user) {
    userDao.update(user);
  }

  @Override
  public void delete(Long id) {
    userDao.delete(id);
  }

  @Override
  @Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
  public User findByKey(Long id) {
    return userDao.findByKey(id);
  }

  @Override
  @Transactional(readOnly = true, propagation = Propagation.SUPPORTS)
  public List<User> findAll() {
    return userDao.findAll();
  }

}
